{% extends '@WebProfiler/Profiler/layout.html.twig' %}

{% block toolbar %}
    {% if collector.tokenClass %}
        {% set color_code = (collector.enabled and collector.authenticated) ? 'green' : 'yellow'  %}
        {% set authentication_color_code = (collector.enabled and collector.authenticated) ? 'green' : 'red'  %}
        {% set authentication_color_text = (collector.enabled and collector.authenticated) ? 'Yes' : 'No'  %}
    {% else %}
        {% set color_code = collector.enabled ? 'red' : 'black'  %}
    {% endif %}
    {% set text %}
        {% if collector.tokenClass %}
            <div class="sf-toolbar-info-piece">
                <b>Logged in as</b>
                <span class="sf-toolbar-status sf-toolbar-status-{{ color_code }}">{{ collector.user }}</span>
            </div>
            <div class="sf-toolbar-info-piece">
                <b>Authenticated</b>
                <span class="sf-toolbar-status sf-toolbar-status-{{ authentication_color_code }}">{{ authentication_color_text }}</span>
            </div>
            {% if collector.tokenClass != null %}
            <div class="sf-toolbar-info-piece">
                <b>Token class</b>
                {{ collector.tokenClass|abbr_class }}
            </div>
            {% endif %}
        {% elseif collector.enabled %}
            You are not authenticated.
        {% else %}
            The security is disabled.
        {% endif %}
    {% endset %}
    {% set icon %}
        <img width="24" height="28" alt="Security" src="" />
        <span class="sf-toolbar-status sf-toolbar-status-{{ color_code }}"></span>
        {% if collector.user %}<div class="sf-toolbar-status sf-toolbar-info-piece-additional">{{ collector.user }}</div>{% endif %}
    {% endset %}
    {% include '@WebProfiler/Profiler/toolbar_item.html.twig' with { 'link': profiler_url } %}
{% endblock %}

{% block menu %}
<span class="label">
    <span class="icon"><img src="" alt="" /></span>
    <strong>Security</strong>
</span>
{% endblock %}

{% block panel %}
    <h2>Security</h2>
    {% if collector.tokenClass %}
        <table>
            <tr>
                <th>Username</th>
                <td>{{ collector.user }}</td>
            </tr>
            <tr>
                <th>Authenticated?</th>
                <td>
                    {% if collector.authenticated %}
                        yes
                    {% else %}
                        no {% if not collector.roles|length %}<em>(probably because the user has no roles)</em>{% endif %}
                    {% endif %}
                </td>
            </tr>
            <tr>
                <th>Roles</th>
                <td>{{ collector.roles|yaml_encode }}</td>
            </tr>
            {% if collector.tokenClass != null %}
            <tr>
                <th>Token class</th>
                <td>{{ collector.tokenClass }}</td>
            </tr>
            {% endif %}
        </table>
    {% elseif collector.enabled %}
        <p>
            <em>No token</em>
        </p>
    {% else %}
        <p>
            <em>The security component is disabled</em>
        </p>
    {% endif %}
{% endblock %}
